Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR: I Read the code. Did the tests, it correctly saves ping data + verifies token (checks if that token hash in database with SHA0256) + checks if the test that ran ran against a existing revision id, checks that the test id in the data measurement json is the same as the test id retrieved from db of the hashed token id. Makes sure that body of the request matches the example json in #4 . Parses it.
Summary
New route
POST /functions/v1/probe-measurements. Probe run test, probe send result here, server save result. One run = one row inmeasurements, and the run ID is the row ID.How it work
schema_version1, UUIDs, RFC 3339 timestamps,finished_atnot beforestarted_at, and nothing more than 5 minutes in the future.X-Probe-Tokenheader against theprobe_idin the body. The token must match an unrevoked credential, and the probe must not be disabled.test_revision_id), not the probe's current assignment.completedneeds exit code 0 and exactly the metric keys indefinition.metrics. Values must be numbers.nullis allowed only for a nullable metric, for example Ping latency when all packets are lost.failedandtimeoutneedresult_data{}.result_codecan be an integer ornull.locationisnullor{latitude, longitude, accuracy_m?}.ON CONFLICT (id) DO NOTHING). The server setsreceived_at, never the probe.Responses (error body is always
{"error":"<code>"}and never echoes the request){"id":"<run id>"}{"id":"<run id>"}invalid_requestunauthorizedmethod_not_allowedconflictpayload_too_largeunknown_revisioninternal_errorFiles
functions/probe-measurements/:index.ts(wiring),handler.ts(request flow),validate.ts(data rules),store.ts(database), and tests.functions/_shared/:probe-auth.ts(token check),http.ts(JSON and error helpers),supabase.ts(service-role client).config.toml:[functions.probe-measurements] verify_jwt = false, because probes have no Supabase JWT. The handler checks the token itself.edge-functionsjob runsdeno lint,deno checkanddeno test --frozen.README.md,server/README.md(contract, test commands, local curl check) andAGENTS.md.deno.jsonanddeno.lockadded.Tokens, request bodies and keys are never logged or returned.
Still to agree before merge
_shared/helpers andconfig.tomloverlap with Verify probes and return their assignments #3 / PR Add probe check-in function and shared probe identity check #9. Decide which PR merges first, and keep one copy ofprobe-auth.ts.Related issue
Closes #4
Testing
From
server/supabase/functions/, Deno 2.9.6:deno lint: pass, 9 files.deno check probe-measurements/index.ts: pass.deno test --frozen: 22 passed, 0 failed. The handler tests use a stand-in token check and an in-memory store, so no backend is needed.From
server/:npx supabase db reset, thennpx supabase test db: 3 files, 85 tests, PASS.npx supabase functions serveand posted to the real route with the seeded token:received_atunchangedrtt_avg_ms: null){}andnullcodemeasurementstable with psql. Only the three accepted runs were saved, and the original row kept its first values and receipt time.Checklist